<?php
require_once("../inc/conn.php");
require_once("../inc/session.php");
$getid = $_GET[ "id" ];
// 传递id到数据表，去找id相同记录值
$sql = "select * from userinfo where id=" . $getid;
$rs=$conn->query($sql);
$row = $rs->fetch_assoc();

//解决选中问题
// 当前用户  使用函数  进行匹配比较   
//检测某字符在字符串中是否存在

?>
<!doctype html>
<html>
<meta charset="utf-8" />
<title>写入信息</title>
</head>

<body>
<form action="saveedit.php" method="post">
  <table width="80%" border="1" align="center" cellpadding="5">
    <tbody>
      <tr>
        <td width="35%" align="center">&nbsp;</td>
        <td width="65%" align="left">修改信息</td>
      </tr>
      <tr>
        <td align="right">用户名：</td>
        <td align="left"><input name="name" type="text" required="required" id="name" value="<?php echo $row["name"];?>">
          <input hidden name="id" type="text" required="required" id="id" value="<?php echo $row["id"];?>"></td>
      </tr>
      <tr>
        <td align="right">选择所属部门：</td>
        <td align="left"><select name="depart" id="depart">
            <option>--请选择--</option>
            <?php
            $ssql = "select * from department order by id desc";
            $srs = mysql_query( $ssql, $conn );
            while ( $srow = mysql_fetch_array( $srs, MYSQL_BOTH ) ) {
              ?>
            <option value="<?php echo $srow[ "id" ];?>"
	<?php if($srow[ "id" ]==$row[ "sortid" ]){ ?> selected="selected"  <?php } ?>
				  ><?php echo $srow[ "name" ];?></option>
            <?php
            }
            ?>
          </select></td>
      </tr>
      <tr>
        <td align="right">密码：</td>
        <td align="left"><input type="password" name="pass" id="pass"></td>
      </tr>
      <tr>
        <td align="right">确认密码:</td>
        <td align="left"><input type="password" name="pass1" id="pass1"></td>
      </tr>
      <tr>
        <td align="right">性别：</td>
        <td align="left"><input type="radio" name="sex" value="女" id="sex_1"  <?php if($row["sex"]=="女"){ ?> checked="checked" <?php } ?>>
          女
          <input type="radio" name="sex" value="男" id="sex_1"  <?php if($row["sex"]=="男"){ ?> checked="checked" <?php } ?>>
          男 </td>
      </tr>
      <tr>
        <td align="right">微信：</td>
        <td align="left"><input name="weixin" type="text" required="required" id="weixin" value="<?php echo $row["weixin"];?>"></td>
      </tr>
      <tr>
        <td align="right">地址：</td>
        <td align="left"><input name="address" type="text" required="required" id="address" size="50" value="<?php echo $row["address"];?>"></td>
      </tr>
      <tr>
        <td align="right">兴趣爱好：</td>
        <td align="left"><input name="ck[]" type="checkbox" id="ck[]" value="踢足球" <?php if(strlen(strpos($row["ck"],"踢足球"))>0){ ?> checked <?php } ?>>
          <label for="label">踢足球 </label>
          <input name="ck[]" type="checkbox" id="ck[]" value="打篮球" <?php if(strlen(strpos($row["ck"],"打篮球"))>0){ ?> checked <?php } ?>>
          <label for="label"> 打篮球 </label>
          <input name="ck[]" type="checkbox" id="ck[]" value="听音乐" <?php if(strlen(strpos($row["ck"],"听音乐"))>0){ ?> checked <?php } ?>>
          <label for="label">听音乐</label>
          <input name="ck[]" type="checkbox" id="ck[]" value="读书" <?php if(strlen(strpos($row["ck"],"读书"))>0){ ?> checked <?php } ?>>
          <label for="label">读书</label>
          <input name="ck[]" type="checkbox" id="ck[]" value="写作" <?php if(strlen(strpos($row["ck"],"写作"))>0){ ?> checked <?php } ?>>
          <label for="label">写作 </label>
          <input name="ck[]" type="checkbox" id="ck[]" value="打乒乓球" <?php if(strlen(strpos($row["ck"],"打乒乓球"))>0){ ?> checked <?php } ?>>
          <label for="label">打乒乓球 </label>
          <input name="ck[]" type="checkbox" id="ck[]" value="旅游" <?php if(strlen(strpos($row["ck"],"旅游"))>0){ ?> checked <?php } ?>>
          <label for="label">旅游 </label></td>
      </tr>
      <tr>
        <td align="right">&nbsp;</td>
        <td align="left"><input type="submit" name="submit" id="submit" value="  立即更新  "></td>
      </tr>
      <tr>
        <td align="right">&nbsp;</td>
        <td align="left">&nbsp;</td>
      </tr>
    </tbody>
  </table>
</form>
</body>
</html>